﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace HoaDon
{
	public static class SqlEXEC
	{
		public static int ExecCommand(string strConn, string strCommand)
		{
			SqlConnection sqlConn = new SqlConnection(strConn);
			sqlConn.Open();
			try
			{
				SqlCommand sqlComm = new SqlCommand(strCommand, sqlConn);
				int i = sqlComm.ExecuteNonQuery();
				sqlConn.Close();
				sqlConn.Dispose();
				return i;
			}
			catch
			{
				sqlConn.Close();
				sqlConn.Dispose();
				return -1;
			}
		}

		public static DataTable GetData(string strConn, string strSelectCommand)
		{
			SqlConnection sqlConn = new SqlConnection(strConn);
			sqlConn.Open();
			try
			{
				SqlDataAdapter sqlDA = new SqlDataAdapter(strSelectCommand, sqlConn);
				DataTable dt = new DataTable();
				sqlDA.Fill(dt);
				sqlConn.Close();
				sqlConn.Dispose();
				return dt;
			}
			catch
			{
				sqlConn.Close();
				sqlConn.Dispose();
				return null;
			}
		}
	}
}
